﻿// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/PanelSlot.h"
#include "Widget/SElementUISlate.h"

#include "ElementUISlot.generated.h"

/**
 * 
 */
UCLASS()
class ELEMENTUIUMG_API UElementUISlot : public UPanelSlot
{
	GENERATED_UCLASS_BODY()
public:
	
	/** The padding area between the slot and the content it contains. */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Layout|Button Slot")
	FMargin Padding;

	/** The alignment of the object horizontally. */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Layout|Button Slot")
	TEnumAsByte<EHorizontalAlignment> HorizontalAlignment;

	/** The alignment of the object vertically. */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Layout|Button Slot")
	TEnumAsByte<EVerticalAlignment> VerticalAlignment;

	public:

	UFUNCTION(BlueprintCallable, Category="Layout|Button Slot")
    void SetPadding(FMargin InPadding);

	UFUNCTION(BlueprintCallable, Category="Layout|Button Slot")
    void SetHorizontalAlignment(EHorizontalAlignment InHorizontalAlignment);

	UFUNCTION(BlueprintCallable, Category="Layout|Button Slot")
    void SetVerticalAlignment(EVerticalAlignment InVerticalAlignment);

	// UPanelSlot interface
	virtual void SynchronizeProperties() override;
	// End of UPanelSlot interface

	/** Builds the underlying slot for the slate button. */
	void BuildSlot(TSharedRef<SElementUISlate> InButton);

	virtual void ReleaseSlateResources(bool bReleaseChildren) override;

private:
	/** A pointer to the button to allow us to adjust the size, padding...etc at runtime. */
	TWeakPtr<SElementUISlate> Button;
};
